package ModelLayer;
import java.io.*;
import java.util.*;
/**
 * Write a description of class Person here.
 * 
 * @author (Group1:Georgi,Roland and Mindaugas) 
 * @version (a version number or a date)
 */
public class Person 
{
   private long ID;
   private String name;
   private String address;
   private String postalCode;
   private String city;
   private String phone;
   private ArrayList<Loan> loans;
  
   /**
    * Constructor of Class Person 
    */
   public Person(long ID, String name, String address, String postalCode, String city, String phone)
    {
        this.ID=ID;
        this.name=name;
        this.address=address;
        this.postalCode=postalCode;
        this.city=city;
        this.phone=phone;
        loans = new ArrayList<Loan>();
    }
    
    //Accesos Methods
    public long getID()
    {
    
        return ID;
       
    }
    
    public String getName()
    {
        return name;
    }
    
    public String getAddress()
    {
        return address;
    }
    
    public String getPostalCode()
    {
        return postalCode;
    }
    
    public String getCity()
    {
        return city;
    }
    
    public String getPhone()
    {
        return phone;
    }
    
    //Mutator Methods
        public void setID(int ID)
    {
        this.ID = ID;
    }
    
    public void setName(String name)
    {
        this.name=name;
    }
    
    public void setAddress(String address)
    {
        this.address = address;
    }
    
    public void setPostalCode(String postalCode)
    {
        this.postalCode = postalCode;
    }
    
    public void setCity(String city)
    {
        this.city = city;
    }
    
    public void setPhone(String phone)
    {
        this.phone = phone;
    }
    
    /**
     * Returns all the loans of the person.
     */
    public ArrayList<Loan> showPersonLoans()
    {
        ArrayList<Loan> localLoans = new ArrayList<Loan>();
        for (int index=0; index<loans.size(); index++){
            localLoans.add(loans.get(index));
            
            
        }
        return localLoans;
    }
    
    /**
     * Associates a loan with a person.
     */
    public void addLoan(Loan loan)
    {
        loans.add(loan);
              
    }
    
    /**
     * Cuts the connection of a loan with a person.
     */
    public void deleteLoan(Loan loan)
    {
        loans.remove(loan);
    }
    
    /**
     * Returns all borrow dates.
     */
    public ArrayList<String> showBorrowDates()
    {
        ArrayList<String> localBorrowDates = new ArrayList<String>();
        for (int index=0; index<loans.size(); index++)
        {
            localBorrowDates.add(loans.get(index).getBorrowDate());        
        } return localBorrowDates;
    } 
    
    /**
     * Returns all periods.
     */
    public ArrayList<Integer> showPeriods()
    {
        ArrayList<Integer> localPeriods = new ArrayList<Integer>();
        for (int index=0; index<loans.size(); index++)
        {
            localPeriods.add(loans.get(index).getPeriod());        
        } return localPeriods;
    }
    
    
    /**
     * Returns all states
     */
     public ArrayList<String> showStates()
    {
        ArrayList<String> localStates = new ArrayList<String>();
        for (int index=0; index<loans.size(); index++)
        {
            localStates.add(loans.get(index).getState());        
        } return localStates;
    }
    

}
